package com.epigeon.amadeo.impl;

import java.util.LinkedList;
import java.util.List;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.epigeon.amadeo.input.ActiveInput;
import com.epigeon.amadeo.input.PassiveInput;
import com.epigeon.amadeo.model.Message;
import com.epigeon.amadeo.modifier.Modifier;
import com.epigeon.amadeo.output.Output;

public abstract class ActiveList extends ListView implements ActiveInput, Output {

	protected List<PassiveInput> passiveInputs = new LinkedList<PassiveInput>();
	protected List<Modifier> modifiers = new LinkedList<Modifier>();
	protected Message message = null;
	
	private int lastLongSelectedItemIndex = -1;	

	private String key = null;
	
	public ActiveList(Context context, AttributeSet attrs) {
		super(context, attrs);

		this.setOnItemLongClickListener(new OnItemLongClickListener() {

			public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
				lastLongSelectedItemIndex = arg2;
				return true;
			}
			
		});
		
	}

	public int getLastSelectedItemIndex() {
		return this.lastLongSelectedItemIndex;
	}
	
	@Override
	public void addPassiveInput(PassiveInput input) {
		passiveInputs.add(input);
	}

	@Override
	public Message getMessage() {
		return this.message;
	}

	@Override
	public List<Modifier> getModifierList() {
		return modifiers;
	}
	
	@Override
	public void addModifier(Modifier modifier) {
		this.modifiers.add(modifier);		
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}
}
